{% extends 'main_hub/search_base.html' %}

{% block title %}
    搜索
{% endblock %}


{% block content %}
    <div class="container">
        {% if not all_user.object_list %}
            <br>
            <div class="row">
                <div class="col-md-12 text-center">
                    <i class="bi bi-search">查询无果</i>
                </div>
            </div>
            <br>
        {% else %}
            <div class="row">
                {% for star in all_user.object_list %}
                    <table class="table">
                        <tbody>
                        <tr>
                            <td>
                                <a href="{% url 'detail_user' %}?user_id={{ star.id }}">
                                    <img class="card-img-top" src="{{ MEDIA_URL }}{{ star.image }}"
                                         style="width: 100px; height: 100px;border-radius:50px">
                                </a>
                            </td>
                            <td style="vertical-align:middle;line-height:20px;">
                                <a href="{% url 'detail_user' %}?user_id={{ star.id }}"
                                   style="text-decoration:none;font-size: 20px;color: darkslategrey; left: -20px">
                                    <br>
                                    {% if star.nick_name %}
                                        {{ star.nick_name }}
                                    {% else %}
                                        {{ star.username }}
                                    {% endif %}
                                    <br>
                                    <p style="color: grey; font-size: 15px">
                                        关注数:<span id="fans_num{{ forloop.counter }}">{{ star.fans }}</span>
                                    </p>
                                </a>
                            </td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td style="vertical-align:middle;line-height:20px;">
                                <button style="width: 100px" id="jsRightBtn" type="button" class="btn btn-primary"
                                        onclick="add_user($(this),{{ star.id }},2,{{ forloop.counter }})">
                                    已关注
                                </button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                {% endfor %}

            </div>
            <div class="row justify-content-center">
                <div class="col-auto" style="margin-top: 50px">
                    <nav aria-label="Page navigation example">
                        <ul class="pagination" style="right:500px">
                            {% if all_user.has_previous %}
                                <li class="page-item">
                                    <a href="?{{ all_user.previous_page_number.querystring }}"
                                       class="page-link" aria-label="Previous">
                                        上一页
                                    </a>
                                </li>
                            {% endif %}
                            {% for page in all_user.pages %}
                                {% if page %}
                                    {% ifequal page all_user.number %}
                                        <li class="page-item">
                                            <a class="page-link" href="?{{ page.querystring }}">{{ page }}</a>
                                        </li>
                                    {% else %}
                                        <li>
                                            <a class="page-link page" href="?{{ page.querystring }}">{{ page }}</a>
                                        </li>
                                    {% endifequal %}
                                {% else %}
                                    <li class="none">...</li>
                                {% endif %}
                            {% endfor %}
                            {% if all_user.has_next %}
                                <li class="page-item">
                                    <a href="?{{ all_user.next_page_number.querystring }}" class="page-link"
                                       aria-label="Next">下一页</a>
                                </li>
                            {% endif %}
                        </ul>
                    </nav>
                </div>
            </div>
        {% endif %}
    </div>
{% endblock %}

